﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TSAE05
    {
        public TSAE05()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VMEVAR();
            DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);              
        } 

       
        public override void OnEXAUFChg(string value)
        {
            TBMain.Clear();
            if (value.Length < 35)
                return; 
            dwData = TMV.TBMain.NewRow();
  
            dwData["MEVMANDANT"] = app.Mandant;
            dwData["MEVAGANG"] = " AND MEVAGANG='" + value.Substring(0, 15) + "'";
            dwData["MEVMTYP"] = " AND MEVMTYP='" + value.Substring(15, 8) + "'";
            dwData["MEVMNRKRS"] = " AND MEVMNRKRS='" + value.Substring(23, 2) + "'";
            dwData["MEVMLFDNR"] = " AND MEVMLFDNR='" + value.Substring(25, 4) + "'";
            dwData["MEVMPOS"] = " AND MEVMPOS='" + value.Substring(29, 2) + "'";
            dwData["MEVEVARHNR"] = " AND MEVEVARHNR='" + value.Substring(31, 2) + "'";
            dwData["MEVEVARUNR"] = " AND MEVEVARUNR='" + value.Substring(33, 2) + "'";
            SResult = TMV.QMER02(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(value);
        }
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM);
            base.LOADBYAUF();
        }

        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnEXAUFChg(EXAUF);
            }
            base.ManageCommand(sender, e);
        } 
    }

}
